--- Makefile.orig	Thu May 15 00:19:43 2014
+++ Makefile	Sun Aug 17 20:09:15 2014
@@ -1,9 +1,8 @@
-PREFIX = /usr/local
 BINDIR = $(PREFIX)/bin
 MANDIR = $(PREFIX)/man
 INFODIR = $(PREFIX)/info
-LOCAL_ROOT = /usr/share/polipo/www
-DISK_CACHE_ROOT = /var/cache/polipo
+LOCAL_ROOT = ${PREFIX}/share/doc/polipo
+DISK_CACHE_ROOT = /var/polipo/cache
 
 # To compile with Unix CC:
 
@@ -12,7 +11,6 @@ DISK_CACHE_ROOT = /var/cache/polipo
 # To compile with GCC:
 
 # CC = gcc
-CDEBUGFLAGS = -Os -g -Wall -fno-strict-aliasing
 
 # To compile on a pure POSIX system:
 
@@ -60,7 +58,7 @@ FILE_DEFINES = -DLOCAL_ROOT=\"$(LOCAL_ROOT)/\" \
 
 DEFINES = $(FILE_DEFINES) $(PLATFORM_DEFINES)
 
-CFLAGS = $(MD5INCLUDES) $(CDEBUGFLAGS) $(DEFINES) $(EXTRA_DEFINES)
+CFLAGS += $(MD5INCLUDES) $(CDEBUGFLAGS) $(DEFINES) $(EXTRA_DEFINES)
 
 SRCS = util.c event.c io.c chunk.c atom.c object.c log.c diskcache.c main.c \
        config.c local.c http.c client.c server.c auth.c tunnel.c \
@@ -86,20 +84,19 @@ all: polipo$(EXE) polipo.info html/index.html localind
 install: install.binary install.man
 
 install.binary: all
-	mkdir -p $(TARGET)$(BINDIR)
-	mkdir -p $(TARGET)$(LOCAL_ROOT)
-	mkdir -p $(TARGET)$(LOCAL_ROOT)/doc
+	${BSD_INSTALL_DATA_DIR} $(TARGET)$(BINDIR)
+	${BSD_INSTALL_DATA_DIR} $(TARGET)$(LOCAL_ROOT)
+	${BSD_INSTALL_DATA_DIR} $(TARGET)$(LOCAL_ROOT)/doc
 	rm -f $(TARGET)$(BINDIR)/polipo
-	cp -f polipo $(TARGET)$(BINDIR)/
-	cp -f html/* $(TARGET)$(LOCAL_ROOT)/doc
-	cp -f localindex.html $(TARGET)$(LOCAL_ROOT)/index.html
+	${BSD_INSTALL_PROGRAM} polipo $(TARGET)$(BINDIR)/
+	${BSD_INSTALL_DATA} html/* $(TARGET)$(LOCAL_ROOT)/doc
+	${BSD_INSTALL_DATA} localindex.html $(TARGET)$(LOCAL_ROOT)/index.html
 
 install.man: all
-	mkdir -p $(TARGET)$(MANDIR)/man1
-	mkdir -p $(TARGET)$(INFODIR)
-	cp -f polipo.man $(TARGET)$(MANDIR)/man1/polipo.1
-	cp polipo.info $(TARGET)$(INFODIR)/
-	install-info --info-dir=$(TARGET)$(INFODIR) polipo.info
+	${BSD_INSTALL_MAN_DIR} $(TARGET)$(MANDIR)/man1
+	${BSD_INSTALL_DATA_DIR} $(TARGET)$(INFODIR)
+	${BSD_INSTALL_MAN} polipo.man $(TARGET)$(MANDIR)/man1/polipo.1
+	${BSD_INSTALL_DATA} polipo.info $(TARGET)$(INFODIR)/
 
 
 polipo.info: polipo.texi
